/**
 */
package org.soyatec.tooling.gef.examples.shapes.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.soyatec.tooling.gef.examples.shapes.Connection;
import org.soyatec.tooling.gef.examples.shapes.Graph;
import org.soyatec.tooling.gef.examples.shapes.Shape;
import org.soyatec.tooling.gef.examples.shapes.ShapesPackage;

/**
 * <!-- begin-user-doc --> An implementation of the model object '
 * <em><b>Graph</b></em>'. <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 * <li>{@link org.soyatec.tooling.gef.examples.shapes.impl.GraphImpl#getShapes
 * <em>Shapes</em>}</li>
 * <li>
 * {@link org.soyatec.tooling.gef.examples.shapes.impl.GraphImpl#getConnections
 * <em>Connections</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GraphImpl extends MinimalEObjectImpl.Container implements Graph {
    /**
     * The cached value of the '{@link #getShapes() <em>Shapes</em>}'
     * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @see #getShapes()
     * @generated
     * @ordered
     */
    protected EList<Shape> shapes;

    /**
     * The cached value of the '{@link #getConnections() <em>Connections</em>}'
     * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @see #getConnections()
     * @generated
     * @ordered
     */
    protected EList<Connection> connections;

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    protected GraphImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return ShapesPackage.Literals.GRAPH;
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    public EList<Shape> getShapes() {
        if (shapes == null) {
            shapes = new EObjectContainmentEList<Shape>(Shape.class, this,
                    ShapesPackage.GRAPH__SHAPES);
        }
        return shapes;
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    public EList<Connection> getConnections() {
        if (connections == null) {
            connections = new EObjectContainmentEList<Connection>(
                    Connection.class, this, ShapesPackage.GRAPH__CONNECTIONS);
        }
        return connections;
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd,
            int featureID, NotificationChain msgs) {
        switch (featureID) {
        case ShapesPackage.GRAPH__SHAPES:
            return ((InternalEList<?>) getShapes()).basicRemove(otherEnd, msgs);
        case ShapesPackage.GRAPH__CONNECTIONS:
            return ((InternalEList<?>) getConnections()).basicRemove(otherEnd,
                    msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
        case ShapesPackage.GRAPH__SHAPES:
            return getShapes();
        case ShapesPackage.GRAPH__CONNECTIONS:
            return getConnections();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    @SuppressWarnings("unchecked")
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
        case ShapesPackage.GRAPH__SHAPES:
            getShapes().clear();
            getShapes().addAll((Collection<? extends Shape>) newValue);
            return;
        case ShapesPackage.GRAPH__CONNECTIONS:
            getConnections().clear();
            getConnections()
                    .addAll((Collection<? extends Connection>) newValue);
            return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
        case ShapesPackage.GRAPH__SHAPES:
            getShapes().clear();
            return;
        case ShapesPackage.GRAPH__CONNECTIONS:
            getConnections().clear();
            return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * 
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
        case ShapesPackage.GRAPH__SHAPES:
            return shapes != null && !shapes.isEmpty();
        case ShapesPackage.GRAPH__CONNECTIONS:
            return connections != null && !connections.isEmpty();
        }
        return super.eIsSet(featureID);
    }

} // GraphImpl
